<!---

Kalendar Admin

COPYRIGHT & LICENSING INFO
-------------------------------------------------------------------

Copyright 2006 TJ Downes - tdownes@sanative.net - http://www.sanative.net

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
  
FCKEditor COPYRIGHT & LICENSING INFO
-------------------------------------------------------------------
This product includes support for FCKEditor.
FCKEditor is developed by Frederico Caldeira Knabben. 
http://www.fckeditor.net/
FCKEditor is licensed under LGPL


DHTML Calendar COPYRIGHT & LICENSING INFO
-------------------------------------------------------------------
This product includes support and libraries for DHTML Calendar.
DHTML Calendar is developed by Mihai Bazon.
http://www.bazon.net/mishoo
DHTML Calendar is licensed under LPGL.

--->
<cfsetting showdebugoutput="false"/>
<cfif URL.fromPublic AND (StructKeyExists(form,'updateRecord') OR StructKeyExists(form,'addRecord') OR (KalendarEvent.getAppAction() EQ 'deleteRecord')) AND ArrayLen(UserMsg.getMsg()) EQ 0>
	<script type="text/javascript">
		parent.tb_remove();
		parent.reloadView();
	</script>
</cfif>
<cfif KalendarEvent.getUserID() NEQ session.user.getUserID() AND NOT Val(KalendarEvent.getIsPublic()) AND KalendarEvent.getAppAction() NEQ 'addRecord'>
	<div>This event may have been removed or you may not have the appropriate permissions to view this event. If you are certain you have permission to view this event please refresh your page.</div>
	<cfabort>
</cfif>
<p class="usermessages"><cfoutput>#UserMsg.display()#</cfoutput></p>
<cfform action="process_event.cfm?fromPublic=#url.fromPublic#" name="eventForm" method="post" onsubmit="return checkIt();">
<input type="hidden" name="appAction" value="<cfoutput>#KalendarEvent.getAppAction()#</cfoutput>" />
<input type="hidden" name="EventID" value="<cfoutput>#KalendarEvent.getEventID()#</cfoutput>" />
<input type="hidden" name="userID" value="<cfoutput>#session.user.getUserID()#</cfoutput>"/>
<input type="hidden" name="userRole" value="<cfoutput>#session.user.getRole()#</cfoutput>"/>
<input type="hidden" name="CategoryID" id="CategoryID" value="00000000-0000-0000-0000000000000000"/>
<div class="tabber">
	<div class="tabbertab" title="Event Info" style="height:275px;">
		<table class="eventEditTable">
			<tr>
				<td class="label"><strong>Title</strong></td>
			  	<td colspan="3"><cfinput id="Title" type="text" name="Title" value="#KalendarEvent.getTitle()#" size="30" class="inputtextfield" required="true" validate="noblanks" message="Title is a required field." /></td>
			</tr>
			<!--- <cfset categoryQuery = KalendarRequest.getCategoriesRS() />
			<tr>
				<td class="label">Category</td>
			    <td colspan="3"><cfselect id="CategoryID" name="CategoryID" query="categoryQuery" display="CategoryName" value="CategoryID" selected="#KalendarEvent.getCategoryID()#" /></td>
			</tr>
			<tr>
				<td class="label">New Category</td>
			  	<td colspan="3"><cfinput id="NewCategoryName" type="text" name="NewCategoryName" size="21" class="inputtextfield" /></td>
			</tr> --->
			<tr>
			    <td class="label"><strong>Start Date</strong></td>
				<cfsilent>
				<cfset startDate = ""/>
				<cfif Len(Trim(KalendarEvent.getStartDate()))>
					<cfset startDate = DateFormat(Request.Timezones.castFromUTC(KalendarEvent.getStartDate(),session.user.getTimezone()),'m/dd/yyyy')>
				</cfif>
				<cfset endDate = ""/>
				<cfif Len(Trim(KalendarEvent.getEndDate()))>
					<cfset endDate = DateFormat(Request.Timezones.castFromUTC(KalendarEvent.getEndDate(),session.user.getTimezone()),'m/dd/yyyy')>
				</cfif>
				</cfsilent>
			  	<td><cfinput id="StartDate" type="text" name="StartDate" value="#startDate#" size="10" class="inputtextfield" required="true" validate="date" message="Start Date is a required field and must be a valid date (m/d/yyyy format)." />
			  	<img src="../common/images/date.gif" id="StartDateImg" alt="start date chooser" /></td>
			  	<td class="rightlabel">End Date</td>
			  	<td><cfinput id="EndDate" type="text" name="EndDate" value="#endDate#" size="10" class="inputtextfield" required="false" validate="date" message="End Date must be a valid date (m/d/yyyy format)." />
			  	<img src="../common/images/date.gif" id="EndDateImg" alt="end date chooser" /></td>
			</tr>
			<cfsilent>
			<cfset variables.startTime = ""/>
			<cfset variables.endTime = ""/>
				
			<cfif NOT KalendarEvent.getIsAllDayEvent()>
				<cfif Len(Trim(KalendarEvent.getStartDate()))>
					<cfset variables.startTime = TimeFormat(Request.Timezones.castFromUTC(KalendarEvent.getStartDate(),session.user.getTimezone()),'h:mm tt')/>
				</cfif>
				<cfif Len(Trim(KalendarEvent.getEndDate()))>
					<cfset variables.endTime = TimeFormat(Request.Timezones.castFromUTC(KalendarEvent.getEndDate(),session.user.getTimezone()),'h:mm tt')/>
				</cfif>
			</cfif>
			</cfsilent>
			<tr>
			    <td class="label">Start Time</td>
			    <td><cfinput id="StartTime" type="text" name="StartTime" value="#variables.startTime#" size="10" class="inputtextfield" required="false" validate="time" message="Start Time must be a valid time." /></td>
			    <td class="rightlabel">End Time</td>
			    <td><cfinput id="EndTime" type="text" name="EndTime" value="#variables.endTime#" size="10" class="inputtextfield" required="false" validate="time" message="End Time must be a valid time." /></td>
			</tr>
			<tr>
				<td class="label">Location</td>
			    <td colspan="3"><cfinput type="text" id="Location" name="Location" value="#KalendarEvent.getLocation()#" size="30" class="inputtextfield" /></td>
			</tr>
			<tr>
				<td class="label">Website</td>
			    <td colspan="3"><cfinput type="text" id="ExternalURL" name="ExternalURL" value="#KalendarEvent.getExternalURL()#" size="30" class="inputtextfield" /></td>
			</tr>
			<tr>
				<td class="label">Contact Name</td>
			    <td colspan="3"><cfinput type="text" id="ContactName" name="ContactName" value="#KalendarEvent.getContactName()#" size="30" class="inputtextfield" /></td>
			</tr>
			<tr>
				<td class="label">E-mail</td>
			    <td colspan="3"><cfinput type="text" id="ContactEmail" name="ContactEmail" value="#KalendarEvent.getContactEmail()#" required="false" validate="email" message="E-mail must be a valid e-mail address." size="30" class="inputtextfield" /></td>
			</tr>
			<tr>
				<td class="label">Phone</td>
			    <td colspan="3"><cfinput type="text" id="ContactPhone" name="ContactPhone" value="#KalendarEvent.getContactPhone()#" size="15" class="inputtextfield" /></td>
			</tr>
			<tr><!---<cfinput type="checkbox" name="IsFeatured" value="1" checked="#YesNoFormat(KalendarEvent.getIsFeatured())#" /> 
			    Featured--->
				<td class="label">Public</td>
				<td><cfinput type="checkbox" id="IsPublic" name="IsPublic" value="1" checked="#YesNoFormat(KalendarEvent.getIsPublic())#" /></td>
				<td class="label">All Day Event</td>
				<td><cfinput type="checkbox" id="IsAllDayEvent" name="IsAllDayEvent" value="1" checked="#YesNoFormat(KalendarEvent.getIsAllDayEvent())#" onclick="toggleTimes();" /></td>
			</tr>
		</table>
	</div>
	<div class="tabbertab" title="Description" style="height:275px;">
		<table class="eventEditTable">
			<tr>
				<td class="taLabel">Teaser</td>
			    <td colspan="3"><textarea id="Teaser" name="Teaser"><cfoutput>#KalendarEvent.getTeaser()#</cfoutput></textarea></td>
			</tr>
			<tr>
				<td class="taLabel" valign="top"><strong>Body</strong></td>
			    <td colspan="3"><cftextarea name="Description" id="Description" 
			    					required="yes"
			    					message="Description is required."
			    					skin="silver"
			    					richtext="yes"
			    					toolbar="Basic"
			    					rows="0" cols="0"
			    					value="#KalendarEvent.getDescription()#"/></td>
			</tr>
		</table>
	</div>
</div>
<table class="eventEditTable">
<tr>
	<td colspan="4" id="buttonbar">
	<cfif KalendarEvent.getAppAction() IS "addRecord">
    	<input name="addRecord" type="submit" value="add record" class="button" />
    <cfelse>
    	<input name="deleteRecord" type="button" value="delete record" class="deletebutton" onclick="removeRecord();" />&nbsp;
        <input name="updateRecord" type="submit" value="update record" class="button" />
    </cfif></td>
</tr>
</table>
</cfform>
<!---	
		the following script defines the Calendar.setup helper function, which makes
   		adding a calendar a matter of 1 or 2 lines of code.
--->
<script type="text/javascript">
    Calendar.setup({
        inputField     :    "StartDate",
        ifFormat       :    "%m/%d/%Y",
        button         :    "StartDateImg",
        align          :    "cc",
        singleClick    :    true
    });
    Calendar.setup({
        inputField     :    "EndDate",
        ifFormat       :    "%m/%d/%Y",
        button         :    "EndDateImg",
        align          :    "cc",
        singleClick    :    true
    });
</script>